#include<iostream>
#include<vector>
#include<string>
#include<stack>
using namespace std;

int evalRPN(vector<string>& tokens) {
    stack<int> st;
    int i = 0, cur = 0;
    for (i = 0; i < tokens.size(); i++)
    {
        cur = 0;
        int right = 0, left = 0;
        if (tokens[i].size() == 1 && tokens[i][0] == '-')
        {
            right = st.top();
            st.pop();
            left = st.top();
            st.pop();
            st.push(left - right);
        }
        else if (tokens[i].size() == 1 && tokens[i][0] == '+')
        {
            right = st.top();
            st.pop();
            left = st.top();
            st.pop();
            st.push(left + right);
        }
        else if (tokens[i][0] == '*')
        {
            right = st.top();
            st.pop();
            left = st.top();
            st.pop();
            st.push(left * right);
        }
        else if (tokens[i][0] == '/')
        {
            right = st.top();
            st.pop();
            left = st.top();
            st.pop();
            st.push(left / right);
        }
        else if (tokens[i].size() > 1 && tokens[i][0] == '-')
        {
            for (int j = 1; j < tokens[i].size(); j++)
            {
                cur = tokens[i][j] - '0' + 10 * cur;
            }
            st.push(-cur);
        }
        else
        {
            for (int j = 0; j < tokens[i].size(); j++)
            {
                cur = tokens[i][j] - '0' + 10 * cur;
            }
            st.push(cur);
        }
    }
    return st.top();
}

int main()
{
    string ps[5] = {"2","1","+","3","*"};
    vector<string> tokens = { ps, ps + 5 };
    printf("%d", evalRPN(tokens));
	return 0;
}